$(function () {
    // alert('ok')
    $('.layui-form').on('submit', function (e) {
        e.preventDefault()
        // console.log('ok');
        var data = $(this).serialize()
        // var data = $(this).serialize()
        // console.log(data);
        $.ajax({
            method: "POST",
            url: '/api/login',
            data,
            success(res) {
                // console.log(res);
                if (res.status !== 0) return layui.layer.msg(res.message, {
                    icon: 5
                })
                layui.layer.msg(res.message, {
                    icon: 6
                })
                localStorage.setItem('token', res.token)
                location.href = './index.html'
            }
        })
    })

    // 粒子效果库
    $('.layui-container').particleground({
        dotColor: '#7ec7fd',
        lineColor: '#7ec7fd'
    });

})